#region Using Statements
using Microsoft.Xna.Framework;
#endregion

namespace PFAGame
{
    class OptionsMenuScreen : MenuScreen
    {
        #region Fields

        MenuEntry musicMenuEntry;
        MenuEntry effectsMenuEntry;
        MenuEntry vSyncMenuEntry;

        static bool vSync = true;

        static int music = 5;
        static int effects = 5;

        #endregion

        #region Initialization

        public OptionsMenuScreen()
            : base("Options")
        {
            // Create our menu entries.
            musicMenuEntry = new MenuEntry(string.Empty);
            effectsMenuEntry = new MenuEntry(string.Empty);
            vSyncMenuEntry = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry back = new MenuEntry("Back");

            // Hook up menu event handlers.
            musicMenuEntry.Selected += MusicMenuEntrySelected;
            effectsMenuEntry.Selected += EffectsMenuEntrySelected;
            vSyncMenuEntry.Selected += VSyncMenuEntrySelected;
            back.Selected += OnCancel;
            
            // Add entries to the menu.
            MenuEntries.Add(musicMenuEntry);
            MenuEntries.Add(effectsMenuEntry);
            MenuEntries.Add(vSyncMenuEntry);
            MenuEntries.Add(back);
        }

        void SetMenuEntryText()
        {
            musicMenuEntry.Text = "Music : " + music;
            effectsMenuEntry.Text = "Effects : " + effects;
            vSyncMenuEntry.Text = "vSync : " + (vSync ? "On" : "Off");
        }


        #endregion

        #region Handle Input

        void MusicMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            music++;

            if (music > 10)
                music = 0;

            SetMenuEntryText();
        }

        void EffectsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            effects++;

            if (effects > 10)
                effects = 0;

            SetMenuEntryText();
        }

        void VSyncMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            vSync = !vSync;

            SetMenuEntryText();
        }

        #endregion
    }
}
